package com.example.lenovo.helloworld;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.media.MediaActionSound;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;


public class MainActivity extends Activity {

    private  EditText editText;
    private ImageView imageView;
    private ProgressBar progressBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);
        Button startNormalActivity=(Button) findViewById(R.id.button_1);
        editText =(EditText) findViewById(R.id.editText_1);
        imageView =(ImageView) findViewById(R.id.imageView);
        progressBar=(ProgressBar)findViewById(R.id.progressBar);


        startNormalActivity.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                       switch (v.getId()){
                           case R.id.button_1:
//                               String inputText=editText.getText().toString();
//                               Toast.makeText(MainActivity.this,inputText,Toast.LENGTH_SHORT).show();
//                               imageView.setImageResource(R.drawable.img_2);
                               if (progressBar.getVisibility()==View.GONE){
                                   progressBar.setVisibility(View.VISIBLE);
                               }else {
                                   progressBar.setVisibility(View.GONE);
                               }
//                               AlertDialog.Builder dialog=new AlertDialog.Builder(MainActivity.this);
//                               dialog.setTitle("this is Dialog");
//                               dialog.setMessage("Something improtant.");
//                               dialog.setCancelable(false);
//                               dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
//                                   @Override
//                                   public void onClick(DialogInterface dialog, int which) {
//
//                                   }
//                               });
//                               dialog.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
//                                   @Override
//                                   public void onClick(DialogInterface dialog, int which) {
//
//                                   }
//                               });
//                               dialog.show();


                               ProgressDialog progressDialog=new ProgressDialog(MainActivity.this);
                               progressDialog.setTitle("this is Progressdialog");
                               progressDialog.setMessage("loading...");
                               progressDialog.setCancelable(true);
                               progressDialog.show();

                               break;
                           default:
                               break;
                       }
                    }
                }

        ); }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
